
#ifndef __DRIVER_NV3047_RGB_H__
#define __DRIVER_NV3047_RGB_H__

#include "fr30xx.h"
#include "app_config.h"
#include "rgb565.h"

#define  RGB_ROW         480
#define  RGB_COLUMN      272

#define RGB565_LCD_DCLK_PORT				GPIOB
#define RGB565_LCD_DCLK_GPIO				GPIO_PIN_14

#define RGB565_LCD_VSYNC_PORT				GPIOB
#define RGB565_LCD_VSYNC_GPIO				GPIO_PIN_13

#define RGB565_LCD_HSYNC_PORT				GPIOB
#define RGB565_LCD_HSYNC_GPIO				GPIO_PIN_15

#define RGB565_LCD_DISP_PORT				GPIOD
#define RGB565_LCD_DISP_GPIO				GPIO_PIN_12

#define RGB565_LCD_DE_EN_PORT				GPIOB
#define RGB565_LCD_DE_EN_GPIO				GPIO_PIN_12

#define RGB565_LCD_DATA_PORT				GPIOC
#define RGB565_LCD_DATA_GPIO				0xFFFF //GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7

#define RGB565_LCD_RESET_PORT				GPIOA
#define RGB565_LCD_RESET_GPIO				GPIO_PIN_4

#define RGB565_LCD_BACKLIGHT_PORT 	  		GPIOA 
#define RGB565_LCD_BACKLIGHT_GPIO 			GPIO_PIN_4
#define RGB565_LCD_SPI_SEL       			SPIM0

#ifdef  RGB565_LCD_TE_EN
#define RGB565_LCD_TE_PORT 	  				GPIO_B
#define RGB565_LCD_TE_GPIO 					GPIO_PIN_7
#endif

//#define RGB56_LCD_INIT_CONFIG					

#ifdef RGB56_LCD_INIT_CONFIG
#define RGB565_LCD_SPI_CS_PORT 	  			GPIOD 
#define RGB565_LCD_SPI_CS_GPIO 				GPIO_PIN_12

#define RGB565_LCD_SPI_CLK_PORT 	  		GPIOB 
#define RGB565_LCD_SPI_CLK_GPIO 			GPIO_PIN_0

#define RGB565_LCD_SPI_MOSI_PORT 	  		GPIOB 
#define RGB565_LCD_SPI_MOSI_GPIO 			GPIO_PIN_2

#define RGB565_LCD_SPI_MISO_PORT 	  		GPIOB
#define RGB565_LCD_SPI_MISO_GPIO 			GPIO_PIN_3

#define rgb_spi_cs_set()		 	 	 gpio_write_pin(RGB565_LCD_SPI_CS_PORT,RGB565_LCD_SPI_CS_GPIO,GPIO_PIN_SET) 	
#define rgb_spi_cs_release()		 	 gpio_write_pin(RGB565_LCD_SPI_CS_PORT,RGB565_LCD_SPI_CS_GPIO,GPIO_PIN_CLEAR)	

#endif

/* signal drive*/
#define rgb_lcd_enable_set()		 	 gpio_write_pin(RGB565_LCD_DE_EN_PORT,RGB565_LCD_DE_EN_GPIO,GPIO_PIN_SET)	
#define rgb_lcd_enable_release()		 gpio_write_pin(RGB565_LCD_DE_EN_PORT,RGB565_LCD_DE_EN_GPIO,GPIO_PIN_CLEAR)	

#define rgb_lcd_vsync_set()		 	 	 gpio_write_pin(RGB565_LCD_VSYNC_PORT,RGB565_LCD_VSYNC_GPIO,GPIO_PIN_SET) 	
#define rgb_lcd_vsync_release()		 	 gpio_write_pin(RGB565_LCD_VSYNC_PORT,RGB565_LCD_VSYNC_GPIO,GPIO_PIN_CLEAR)	

#define rgb_lcd_hsync_set()		 	 	 gpio_write_pin(RGB565_LCD_HSYNC_PORT,RGB565_LCD_HSYNC_GPIO,GPIO_PIN_SET) 	
#define rgb_lcd_hsync_release()			 gpio_write_pin(RGB565_LCD_HSYNC_PORT,RGB565_LCD_HSYNC_GPIO,GPIO_PIN_CLEAR)	

#define rgb_lcd_reset_set()		 	 	 gpio_write_pin(RGB565_LCD_RESET_PORT,RGB565_LCD_RESET_GPIO,GPIO_PIN_SET) 	
#define rgb_lcd_reset_release()		 	 gpio_write_pin(RGB565_LCD_RESET_PORT,RGB565_LCD_RESET_GPIO,GPIO_PIN_CLEAR)	

#define rgb_lcd_disp_set()		 	 	 gpio_write_pin(RGB565_LCD_DISP_PORT,RGB565_LCD_DISP_GPIO,GPIO_PIN_SET) 	
#define rgb_lcd_disp_release()		 	 gpio_write_pin(RGB565_LCD_DISP_PORT,RGB565_LCD_DISP_GPIO,GPIO_PIN_CLEAR)	

#define rgb_lcd_backlight_set()		 	 gpio_write_pin(RGB565_LCD_BACKLIGHT_PORT,RGB565_LCD_BACKLIGHT_GPIO,GPIO_PIN_SET) 	
#define rgb_lcd_backlight_release()		 gpio_write_pin(RGB565_LCD_BACKLIGHT_PORT,RGB565_LCD_BACKLIGHT_GPIO,GPIO_PIN_CLEAR)	

/* Exported functions --------------------------------------------------------*/

/* rgb_demo */
void rgb_display_init(void* buffer);
void rgb_display_controller_init(void);


__RAM_CODE void rgb_display_dma_irq(void);


#endif
